package com.teach.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.teach.commons.Id;
import com.teach.entity.RotationChart;
import com.teach.exception.CodeException;
import com.teach.mapper.RotationChartMapper;
import com.teach.service.RotationChartService;
@Service
public class RotationChartServiceImpl implements RotationChartService{

	@Autowired
	private RotationChartMapper mapper;
	
	@Autowired
	private Id id;
	
	@Override
	public void add(RotationChart record) {
		try {
			record.setImgId(id.nextId());
			mapper.insert(record);
		} catch (Exception e) {
			throw new CodeException(5004);
		}
	}

	@Override
	public void delete(Long imgId) {
		try {
			mapper.deleteByPrimaryKey(imgId);
		} catch (Exception e) {
			throw new CodeException(5005);
		}
	}

	@Override
	public RotationChart get(Long imgId) {
		try {
			return mapper.selectByPrimaryKey(imgId);
		} catch (Exception e) {
			throw new CodeException(5006);
		}
		
	}

	@Override
	public List<RotationChart> listAll() {
		try {
			return mapper.selectAll();
		} catch (Exception e) {
			throw new CodeException(5006);
		}
	}

	@Override
	public void modify(RotationChart rtc) {
		try {
			mapper.updateByPrimaryKey(rtc);
		} catch (Exception e) {
			throw new CodeException(5007);
		}
	}


}
